package com.servlet;

import com.Dao.BookDao;
import com.Dao.BorrowDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "returnBookServlet", value = "/returnBookServlet")
public class returnBookServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        int bookId= Integer.parseInt(request.getParameter("bookId"));
        int userNum= Integer.parseInt(request.getParameter("usernum"));
        BorrowDao borrowDao = new BorrowDao();
        borrowDao.returnBook(bookId, userNum);
        BookDao bookDao = new BookDao();
        bookDao.updateBook1(bookId);
        response.sendRedirect("borrowInfoServlet");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
